package com.wang.service;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.pojo.User;
import com.wang.port.RpcPort;
import com.wang.proxy.RpcClientProxy;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by wangq on 2021/8/29.
 */
@Service
@Configuration
@ConfigurationProperties(prefix = "rpc")
public class UserService {

    private static List<RpcPort> serverList;

    public String findUserById(int id) {
        System.out.println("查询用户id=" + id);
        IUserService userService = (IUserService) RpcClientProxy.createProxy(IUserService.class);
        User user = userService.getById(id);
        return user.toString();
    }
}
